package axonactive.vision.training.dao;

import java.util.List;

import axonactive.vision.training.entity.Question;

import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.process.data.persistence.IIvyEntityManager;

public class QuestionDAO {
private IIvyEntityManager entityManager;
	
	public QuestionDAO(){
		entityManager = Ivy.persistence().get("IvyTraining");
	}
	
	public List<Question> getListQuestionByExamId(int examId){
		return (List<Question>) entityManager.createQuery("from Question where examID = :examId")
					.setParameter("examId", examId)
					.getResultList();
	}
	
	public void removeQuesByExamId(int examId){
		entityManager.createQuery("delete from Question where examID = :examId")
						.setParameter("examId", examId)
						.executeUpdate();
	}
	
	public void removeQues(Question ques){
		entityManager.remove(ques);
	}
	
	public void mergeQues(Question question){
		entityManager.merge(question);
	}
}
